Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/timestamp validation class #446

Merged
merged 10 commits into from
Dec 11, 2024
Merged

Conversation

divinecharlotte
Copy link
Contributor

@divinecharlotte divinecharlotte commented Nov 12, 2024

Created meter read timestamp custom validation

  • Move the timestamp validation into custom validation class instead of being in the controller
  • The validators should be in /src/validations

Issue ticket #444 and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • No existing features have been broken without good reason.
  • The code style guidelines have been followed

@divinecharlotte divinecharlotte linked an issue Nov 12, 2024 that may be closed by this pull request
Comment on lines 695 to 722
const dateTime = momentTimeZone.tz(ele[key], measurements.timezone);
let milliSeondsToAddSentInRequest = '';
if (
ele[key].toString().includes('.') &&
!isNaN(
parseInt(
ele[key]
.toString()
.substring(
ele[key].toString().indexOf('.'),
ele[key].toString().length,
),
),
)
) {
milliSeondsToAddSentInRequest = ele[key]
.toString()
.substring(
ele[key].toString().indexOf('.'),
ele[key].toString().length,
);
}
let utcString: string = dateTime.clone().utc().format();

if (milliSeondsToAddSentInRequest != '') {
utcString =
utcString.substring(0, utcString.length - 1) +
milliSeondsToAddSentInRequest +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seem like we don't need this codes.

Kingcedru
Kingcedru previously approved these changes Nov 14, 2024

return value.every((ele) => {
const startTimestamp = ele.starttimestamp;
const endTimestamp = ele.endtimestamp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should validate the timestamp individually

/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.{0,1}\d{0,3}Z?$/;

return value.every((ele) => {
const startTimestamp = ele.starttimestamp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't work. Here were are assuming that we are validating an object which contains both the startTimestmap and endTimestamp which is not the case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@musayann I did so because there will be a time when we will validate both, mainly history read, and when it's only one of them validate it alone. So, I am not getting what you mean here. I am probably missing something out. May you provide more clarification?

} else {
utcString =
utcString.substring(0, utcString.length - 1) + '.000Z';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is not implemented. We should have a transformer for it

@musayann musayann force-pushed the ft/timestamp-validation-class branch from 930ca1e to 5fac77d Compare November 26, 2024 17:08
@musayann musayann force-pushed the ft/timestamp-validation-class branch from 5fac77d to 06d276b Compare November 26, 2024 17:09
Kingcedru
Kingcedru previously approved these changes Nov 29, 2024
musayann
musayann previously approved these changes Dec 10, 2024
@musayann musayann dismissed stale reviews from Kingcedru and themself via 6bb4711 December 10, 2024 17:37
musayann
musayann previously approved these changes Dec 10, 2024
@musayann musayann merged commit 385632d into develop Dec 11, 2024
9 checks passed
@musayann musayann deleted the ft/timestamp-validation-class branch December 11, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create meter read timestamp custom validation
3 participants